error

fun <T> error(storedVal: T, errorEntry: ValidationResult.ErrorEntry): ValidationResult<T>

Create a validation result with this if there was a problem during validation.

In this case, typically, storedVal will be the default value associated with this validation. A valid instance of T must always be passed back. Add a descriptive error message to errorContext. If there is no default, you will want to make your result type nullable and pass back null

Return

the errored ValidationResult

Author

fzzyhmstrs

Since

0.7.0

Parameters

T

Type of result

storedVal

default or fallback instance of type T

errorEntry

ErrorEntry the error to pass with this result


Create a validation result with this if there was a problem during validation.

If storing a simple string error message, consider the overload that accepts a ErrorEntry.Type and simple message/throwable inputs

In this case, typically, storedVal will be the default value associated with this validation. A valid instance of T must always be passed back. Add a descriptive error message to errorContext. If there is no default, you will want to make your result type nullable and pass back null

Return

the errored ValidationResult

Author

fzzyhmstrs

Since

0.7.0

Parameters

T

Type of result

C

Type of error content to store. This is usually a string message

storedVal

default or fallback instance of type T

type

ErrorEntry.Type<C> the error type. When in doubt, use Errors.BASIC

builder

UnaryOperator<ErrorEntry.Builder> operator for applying content to a provided error builder


Create a validation result with this if there was a problem during validation.

In this case, typically, storedVal will be the default value associated with this validation. A valid instance of T must always be passed back. Add a descriptive error message to errorContext. If there is no default, you will want to make your result type nullable and pass back null

Return

the errored ValidationResult

Author

fzzyhmstrs

Since

0.7.0

Parameters

T

Type of result

storedVal

default or fallback instance of type T

type

ErrorEntry.Type the string-based error type. When in doubt, use Errors.BASIC

error

string with error message

e

Throwable, optional, default null. Exception to pass if this result is critically errored


fun <T> error(storedVal: T, error: String): ValidationResult<T>

Deprecated

Plain error strings are deprecated but acceptable. Most of the time passing in ErrorContext is preferred

Create a validation result with this if there was a problem during validation.

In this case, typically, storedVal will be the default value associated with this validation. A valid instance of T must always be passed back. Add a descriptive error message to error. If there is no default, you will want to make your result type nullable and pass back null

Return

the errored ValidationResult

Author

fzzyhmstrs

Since

0.1.0, deprecated 0.7.0

Parameters

T

Type of result

storedVal

default or fallback instance of type T

error

string with error message